package Operate;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

//添加图书
public class AddOperate implements IOOperate{
    @Override
    public void work(BookList bookList) {

        System.out.println("Add");
        System.out.println("book-name:");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("author:");
        String author = scanner.nextLine();
        System.out.println("type:");
        String type = scanner.nextLine();
        System.out.println("price");
        double price = scanner.nextDouble();

        //生成一本书
        Book book = new Book(name,author,price,type);
        //放入书架
        int bookSize = bookList.getBookNumber();
        if(bookSize < 10){
            bookList.putBook(book,bookSize);
            bookList.setBookNumber(bookSize+1);
        }
    }
}
